package com.demo.controller;

import com.demo.entity.DogDto;
import com.demo.entity.ResultVo;
import com.demo.mq.producter.MqProductor;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.amqp.utils.MapBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/demo")
public class TestController {

    @Autowired
    private MqProductor mqProductor;

    @RequestMapping("/sendMsg")
    public ResultVo sendMsg(){
        mqProductor.sendMessage("我乃常山赵子龙");
        return ResultVo.success();
    }

    @RequestMapping("/sendObject")
    public ResultVo sendObject() {
        mqProductor.sendMessage(new DogDto("张三", "黑色", new String[]{"小张","小刘"}));
        return ResultVo.success();
    }

    @RequestMapping("/sendMap")
    public ResultVo sendMap(){
        Map<String,Object> map = new HashMap<>();
        map.put("name", "zhanghe");
        map.put("dog", new DogDto("张三", "黑色", new String[]{"小张","小刘"}));
        mqProductor.sendMessage(map);
        return ResultVo.success();
    }
}
